using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace LigerMVC.Entities.Mapping
{
    public class CF_UserRoleMap : EntityTypeConfiguration<CF_UserRole>
    {
        public CF_UserRoleMap()
        {
            // Primary Key
            this.HasKey(t => t.UserRoleID);

            // Properties
            this.Property(t => t.RecordStatus)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.Guid)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("CF_UserRole");
            this.Property(t => t.UserRoleID).HasColumnName("UserRoleID");
            this.Property(t => t.UserID).HasColumnName("UserID");
            this.Property(t => t.RoleID).HasColumnName("RoleID");
            this.Property(t => t.RecordStatus).HasColumnName("RecordStatus");
            this.Property(t => t.CreateUserID).HasColumnName("CreateUserID");
            this.Property(t => t.CreateDate).HasColumnName("CreateDate");
            this.Property(t => t.ModifyUserID).HasColumnName("ModifyUserID");
            this.Property(t => t.ModifyDate).HasColumnName("ModifyDate");
            this.Property(t => t.Guid).HasColumnName("Guid");

            // Relationships
            this.HasOptional(t => t.CF_User)
                .WithMany(t => t.CF_UserRole)
                .HasForeignKey(d => d.UserID);

        }
    }
}
